# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=recon-ng
pkgver=v5.1.2.r7.gc08acee
pkgrel=1
epoch=2
groups=('blackarch' 'blackarch-recon')
pkgdesc='A full-featured Web Reconnaissance framework written in Python.'
arch=('any')
url='https://github.com/lanmaster53/recon-ng'
license=('GPL-3.0-or-later')
depends=('python' 'python-dicttoxml' 'python-dnspython' 'python-unicodecsv'
         'python-jsonrpclib-pelix' 'python-lxml' 'python-mechanize'
         'python-slowaes' 'python-xlsxwriter' 'python-olefile' 'python-pypdf2'
         'python-flask' 'python-pyaml' 'python-requests' 'python-flask-restful'
         'python-flasgger' 'python-rq')
makedepends=('git')
source=("git+https://github.com/lanmaster53/$pkgname.git")
sha512sums=('SKIP')

pkgver() {
  cd $pkgname

  ( set -o pipefail
    git describe --long --tags --abbrev=7 2>/dev/null |
      sed 's/\([^-]*-g\)/r\1/;s/-/./g' ||
    printf "%s.%s" "$(git rev-list --count HEAD)" \
      "$(git rev-parse --short=7 HEAD)"
  )
}

package() {
  cd $pkgname

  _bins='recon-ng recon-cli recon-web'

  install -dm 755 "$pkgdir/usr/bin"
  install -dm 755 "$pkgdir/usr/share/$pkgname"

  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname" README.md REQUIREMENTS \
    VERSION
  install -Dm 644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"

  rm LICENSE README.md

  cp -a * "$pkgdir/usr/share/$pkgname/"

  for bin in $_bins; do
    cat >> "$pkgdir/usr/bin/$bin" << EOF
#!/bin/sh
cd /usr/share/$pkgname
exec python $bin "\$@"
EOF
    chmod +x "$pkgdir/usr/bin/$bin"
  done
}

